#pragma once

#include <vector>
#include "IResourceObject.h"
#include "SoundHelpers.h"
#include <d3d9.h>
#include "oal/al.h"


enum RESOURCETYPE
{
	CASGE_RES_SPRITE	= 3,
	CASGE_RES_TEXT,
	CASGE_RES_BMPFONT,
	CASGE_RES_BMPTEXT,
	CASGE_RES_SNDSOURCE
};


class CD3D9Engine;

class CResourceFactory
{
	protected:
		struct _TEXREG
		{
			unsigned int hash;
			unsigned int ref;
			LPDIRECT3DTEXTURE9 texture;
		};

		struct _SNDBUFFREG
		{
			unsigned int hash;
			unsigned int ref;
			ALuint bufferID;
		};

		std::vector<_TEXREG*>*			m_textureRegistry;
		std::vector<_SNDBUFFREG*>*		m_soundBufferRegistry;


	private:
		CD3D9Engine* _ptrEngine;


	public:
		CResourceFactory(CD3D9Engine* engine);
		~CResourceFactory();


		IResourceObject* CreateResource(RESOURCETYPE type);

		LPDIRECT3DTEXTURE9	RegisterTexture(const char* fileName, int* width, int* height, DWORD colorKey);
		ALuint RegisterSoundBuffer(const char* fileName, SND_FILETYPE fileType);

		void UnregisterTexture(const char* fileName);
		void UnregisterSoundBuffer(const char* fileName);
};